package condition;

import elements.Element;
import elements.Robot;

/**
 * A class of unary basic conditions.
 * 
 * @version	3.0
 * @author 	Lies Tambeur 	r0264469	2Bcwsbbh
 * @author	Eline Vanrykel	r0264543	2Bcwselt
 *
 */
public class AtItem extends UnaryBasicCondition {

	/**
	 * Returns true only if the element is able to pick up items and is located on a board and
	 * the element is located on the same position as another item.
	 */
	@Override
	public boolean evaluate(Element element) {
		if(element instanceof Robot){
			return (element.getBoard()!=null) && (element.getBoard().getElements(element.getPosition()).size()>1);
		}
		else{
			return false;
		}
		
	}
	
	@Override
	public String toString(){
		return "(at-item)";
	}
	
	@Override
	public boolean equals(Object object){
		if(object == null || this==null){
			return false;
		}
		return this.toString().equals(object.toString());
	}

}
